//
//  EditOneLineViewController.m
//  ForYourBeauty
//
//  Created by Kelly xu on 2019/6/5.
//  Copyright © 2019 changrenTech. All rights reserved.
//

#import "EditOneLineViewController.h"
@interface EditOneLineViewController (){
    
}
@property(nonatomic,weak)IBOutlet UITextField *nickNameText;
@end

@implementation EditOneLineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.navigationItem.title = @"设置昵称";
    [self setNavTitleColor:[UIColor blackColor]];
    [self setNavLeftBtn:@"关闭" color:[UIColor blackColor]];
    [self setNavRightBtn:@"保存" color:Color(@"FF6F61")];
    if (!EC_ISNullStr([LoginTools sharedTools].userInfoModel.userNickname)) {
        self.nickNameText.text = [NSString stringWithFormat:@"%@",[LoginTools sharedTools].userInfoModel.userNickname];
    }
}
-(void)rightbuttonPressed:(id)sender{
    if (!EC_ISNullStr(self.nickNameText.text)) {
        if ([self.nickNameText.text isEqualToString:[LoginTools sharedTools].userInfoModel.userNickname]) {
            [self.rt_navigationController popViewControllerAnimated:YES complete:nil];
        }else{
            [[HttpClient shareClient] postWithUrl:UPDATE_USERINFO params:@{@"id":[LoginTools sharedTools].userId,@"userNickname":self.nickNameText.text} suc:^(id results) {
                [self.rt_navigationController popViewControllerAnimated:YES complete:nil];
            } fail:^(NSString *error, NSInteger status) {
                Toast(error);
            }];
        }
    }
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
